
angular.module("crawlerApp").controller("detailCtrl",function($scope,$http,$state,$stateParams){
   $scope.page=0;
    getCrawlerUrlByRuleId();
    function getCrawlerUrlByRuleId(){
        var json={
          data:$stateParams.config.id,
            page:$scope.page
        };
        $http.post("crawler/config/getCrawlerUrlByRuleId", json).then(function(response) {
            $scope.cawlerUrlList = response.data.content;
            $scope.currentPage=response.data.number;
            $scope.totalPage=response.data.totalPages;
            $scope.totalCount=response.data.totalElements;
        });
    }

    $scope.Previous=function (page) {
        if(page-1>=0){
            $scope.page=page-1;
        }
        getCrawlerUrlByRuleId()
    };

    $scope.Next=function(page){
        if(page+1<=$scope.totalPage-1){
            $scope.page=page+1;
        }
        getCrawlerUrlByRuleId()
    };

    $scope.goto=function (page) {
        if(Number(page)<=$scope.totalPage&&Number(page)>0){
            $scope.page=Number(page)-1;
        }
        getCrawlerUrlByRuleId()
    };

    $scope.goBack=function () {
        $state.go("simpleConfig");
    }



});
